function connection(url) {
    webSocket=new WebSocket(url);
    webSocket.onopen=function () {
        isConnection=true;
        sendAble=false;
        I.imgCode=MyImgCode;
        sendMsg(1,I);
    };
    webSocket.onmessage=function (msg) {
        sendAble=true;
        var js=JSON.parse(msg.data);
        switch (js.code){
            case 1:
                persons=js.content.m;
                walls=js.content.w;
                bullets=js.content.b;
                healthPlace=js.content.h;
                powerPlace=js.content.p;
                if(js.content.e)
                bangs.push(js.content.e);
                break;
        }
    };
    webSocket.onclose=function () {
        isConnection=false;
    };
}
function sendMsg(code,msg) {
    webSocket.send(code+JSON.stringify(msg));
}
